<template>
  <a-card :bordered="false">
    <component @onEdit="handleEdit" @onGoBack="handleGoBack" :gameId="gameId" :is="currentComponet"/>
  </a-card>
</template>

<script>
  // 动态切换组件
  import List from '@/perm/views/qywx/hdgl/HdglList'
  import Edit from '@/perm/views/qywx/hdgl/HdglEdit'

  export default {
    name: 'HdglPage',
    components: {
      List,
      Edit
    },
    data () {
      return {
        currentComponet: 'List',
        gameId: null
      }
    },
    methods: {
      handleEdit (gameId) {
        this.gameId = gameId
        this.currentComponet = 'Edit'
      },
      handleGoBack () {
        this.gameId = null
        this.currentComponet = 'List'
      },
      init () {
        // 如果点击的新建裂变直接进入编辑页
        const path = this.$route.path
        if (path === '/qywx/lbhk/xjlb') {
          this.handleEdit()
        }
      }
    },
    watch: {
      '$route.path' () {
        this.record = ''
        this.currentComponet = 'List'
      }
    },
    mounted () {
      this.init()
    }
  }
</script>
